/*
 * To change this template, choose Tools | Templates
 * and open the template in the editor.
 */

/*
 * DetailedCriminal.java
 *
 * Created on Aug 26, 2011, 5:34:10 PM
 */
package Views;

import Models.Criminal;
import Models.Prisoner;
import Models.Wanted;
import java.awt.Color;
import java.awt.event.MouseEvent;
import java.awt.event.MouseListener;
import java.text.DateFormat;
import java.text.FieldPosition;
import java.text.ParsePosition;
import java.text.SimpleDateFormat;
import java.util.Date;
import javax.swing.ImageIcon;

/**
 *
 * @author Pan
 */
public class DetailedPrisoner extends javax.swing.JDialog {

    Prisoner prisoner;

    /** Creates new form DetailedCriminal */
    public DetailedPrisoner(java.awt.Frame parent, boolean modal) {
        super(parent, modal);
        initComponents();
    }

    public DetailedPrisoner(java.awt.Frame parent, boolean modal, final Prisoner prisoner) {
        super(parent, modal);
        initComponents();

        this.prisoner = prisoner;
        lblPrisonerName.setText(prisoner.getRelatedCriminal().getFullName());
        SimpleDateFormat DateFormat = new SimpleDateFormat("MM/dd/yyyy");
        lblImprisonDate.setText(DateFormat.format(prisoner.getImprisonDate()));
        if (prisoner.getReleaseDate() != null) {
            lblReleaseDate.setText(DateFormat.format(prisoner.getReleaseDate()));
        } else {
            lblReleaseDate.setText("None");
        }
        lblPrisonName.setText(prisoner.getPrisonName());
        System.out.println(this);
        lblCellNumber.setText(prisoner.getCellNumber());
        if (prisoner.isIsReleased()) {
            lblIsReleased.setText("Yes");
        } else {
            lblIsReleased.setText("No");
        }
        txtReleaseReason.setText(prisoner.getReleaseReason());
    }

    /** This method is called from within the constructor to
     * initialize the form.
     * WARNING: Do NOT modify this code. The content of this method is
     * always regenerated by the Form Editor.
     */
    @SuppressWarnings("unchecked")
    // <editor-fold defaultstate="collapsed" desc="Generated Code">//GEN-BEGIN:initComponents
    private void initComponents() {

        jPanel1 = new javax.swing.JPanel();
        jLabel1 = new javax.swing.JLabel();
        btn_Close = new javax.swing.JButton();
        jLabel2 = new javax.swing.JLabel();
        lblPrisonerName = new javax.swing.JLabel();
        jLabel3 = new javax.swing.JLabel();
        lblImprisonDate = new javax.swing.JLabel();
        jLabel5 = new javax.swing.JLabel();
        lblReleaseDate = new javax.swing.JLabel();
        jLabel7 = new javax.swing.JLabel();
        lblPrisonName = new javax.swing.JLabel();
        jLabel9 = new javax.swing.JLabel();
        lblCellNumber = new javax.swing.JLabel();
        jLabel11 = new javax.swing.JLabel();
        lblIsReleased = new javax.swing.JLabel();
        jLabel13 = new javax.swing.JLabel();
        jScrollPane1 = new javax.swing.JScrollPane();
        txtReleaseReason = new javax.swing.JTextArea();

        setDefaultCloseOperation(javax.swing.WindowConstants.DISPOSE_ON_CLOSE);

        jPanel1.setBorder(javax.swing.BorderFactory.createLineBorder(new java.awt.Color(0, 0, 0), 2));
        jPanel1.setPreferredSize(new java.awt.Dimension(613, 50));

        jLabel1.setFont(new java.awt.Font("Tahoma", 0, 24));
        jLabel1.setText("Prisoner Profile Card");

        javax.swing.GroupLayout jPanel1Layout = new javax.swing.GroupLayout(jPanel1);
        jPanel1.setLayout(jPanel1Layout);
        jPanel1Layout.setHorizontalGroup(
            jPanel1Layout.createParallelGroup(javax.swing.GroupLayout.Alignment.LEADING)
            .addGroup(jPanel1Layout.createSequentialGroup()
                .addContainerGap()
                .addComponent(jLabel1)
                .addContainerGap(284, Short.MAX_VALUE))
        );
        jPanel1Layout.setVerticalGroup(
            jPanel1Layout.createParallelGroup(javax.swing.GroupLayout.Alignment.LEADING)
            .addGroup(jPanel1Layout.createSequentialGroup()
                .addContainerGap()
                .addComponent(jLabel1)
                .addContainerGap(javax.swing.GroupLayout.DEFAULT_SIZE, Short.MAX_VALUE))
        );

        btn_Close.setText("Close");
        btn_Close.addActionListener(new java.awt.event.ActionListener() {
            public void actionPerformed(java.awt.event.ActionEvent evt) {
                btn_CloseActionPerformed(evt);
            }
        });

        jLabel2.setText("Prisoner Name:");

        lblPrisonerName.setText("lblPrisonerName");
        lblPrisonerName.addMouseListener(new java.awt.event.MouseAdapter() {
            public void mouseEntered(java.awt.event.MouseEvent evt) {
                lblPrisonerNameMouseEntered(evt);
            }
            public void mouseExited(java.awt.event.MouseEvent evt) {
                lblPrisonerNameMouseExited(evt);
            }
            public void mousePressed(java.awt.event.MouseEvent evt) {
                lblPrisonerNameMousePressed(evt);
            }
        });

        jLabel3.setText("Imprison Date:");

        lblImprisonDate.setText("lblImprisonDate");

        jLabel5.setText("Release Date:");

        lblReleaseDate.setText("lblReleaseDate");

        jLabel7.setText("Prison Name:");

        lblPrisonName.setText("lblPrisonName");

        jLabel9.setText("Cell Plate:");

        lblCellNumber.setText("lblCellNumber");

        jLabel11.setText("Is Released?");

        lblIsReleased.setText("lblIsReleased");

        jLabel13.setText("Release Reason:");

        txtReleaseReason.setColumns(20);
        txtReleaseReason.setEditable(false);
        txtReleaseReason.setLineWrap(true);
        txtReleaseReason.setRows(5);
        jScrollPane1.setViewportView(txtReleaseReason);

        javax.swing.GroupLayout layout = new javax.swing.GroupLayout(getContentPane());
        getContentPane().setLayout(layout);
        layout.setHorizontalGroup(
            layout.createParallelGroup(javax.swing.GroupLayout.Alignment.LEADING)
            .addComponent(jPanel1, javax.swing.GroupLayout.DEFAULT_SIZE, 515, Short.MAX_VALUE)
            .addGroup(layout.createSequentialGroup()
                .addContainerGap()
                .addGroup(layout.createParallelGroup(javax.swing.GroupLayout.Alignment.LEADING)
                    .addGroup(layout.createSequentialGroup()
                        .addComponent(jLabel2)
                        .addPreferredGap(javax.swing.LayoutStyle.ComponentPlacement.RELATED)
                        .addComponent(lblPrisonerName))
                    .addGroup(layout.createSequentialGroup()
                        .addComponent(jLabel3)
                        .addPreferredGap(javax.swing.LayoutStyle.ComponentPlacement.RELATED)
                        .addComponent(lblImprisonDate))
                    .addGroup(layout.createSequentialGroup()
                        .addComponent(jLabel5)
                        .addPreferredGap(javax.swing.LayoutStyle.ComponentPlacement.RELATED)
                        .addComponent(lblReleaseDate))
                    .addGroup(layout.createSequentialGroup()
                        .addComponent(jLabel9)
                        .addPreferredGap(javax.swing.LayoutStyle.ComponentPlacement.RELATED)
                        .addComponent(lblCellNumber))
                    .addGroup(layout.createSequentialGroup()
                        .addComponent(jLabel7)
                        .addPreferredGap(javax.swing.LayoutStyle.ComponentPlacement.RELATED)
                        .addComponent(lblPrisonName)))
                .addGap(89, 89, 89)
                .addGroup(layout.createParallelGroup(javax.swing.GroupLayout.Alignment.LEADING)
                    .addComponent(jLabel13)
                    .addGroup(layout.createSequentialGroup()
                        .addComponent(jLabel11)
                        .addPreferredGap(javax.swing.LayoutStyle.ComponentPlacement.RELATED)
                        .addComponent(lblIsReleased))
                    .addComponent(jScrollPane1, javax.swing.GroupLayout.DEFAULT_SIZE, 251, Short.MAX_VALUE))
                .addContainerGap())
            .addGroup(javax.swing.GroupLayout.Alignment.TRAILING, layout.createSequentialGroup()
                .addContainerGap(446, Short.MAX_VALUE)
                .addComponent(btn_Close)
                .addContainerGap())
        );
        layout.setVerticalGroup(
            layout.createParallelGroup(javax.swing.GroupLayout.Alignment.LEADING)
            .addGroup(layout.createSequentialGroup()
                .addComponent(jPanel1, javax.swing.GroupLayout.PREFERRED_SIZE, 50, javax.swing.GroupLayout.PREFERRED_SIZE)
                .addGap(18, 18, 18)
                .addGroup(layout.createParallelGroup(javax.swing.GroupLayout.Alignment.BASELINE)
                    .addComponent(jLabel2)
                    .addComponent(lblPrisonerName)
                    .addComponent(jLabel11)
                    .addComponent(lblIsReleased))
                .addPreferredGap(javax.swing.LayoutStyle.ComponentPlacement.RELATED)
                .addGroup(layout.createParallelGroup(javax.swing.GroupLayout.Alignment.BASELINE)
                    .addComponent(jLabel3)
                    .addComponent(lblImprisonDate)
                    .addComponent(jLabel13))
                .addPreferredGap(javax.swing.LayoutStyle.ComponentPlacement.RELATED)
                .addGroup(layout.createParallelGroup(javax.swing.GroupLayout.Alignment.LEADING)
                    .addGroup(layout.createSequentialGroup()
                        .addGroup(layout.createParallelGroup(javax.swing.GroupLayout.Alignment.BASELINE)
                            .addComponent(jLabel5)
                            .addComponent(lblReleaseDate))
                        .addPreferredGap(javax.swing.LayoutStyle.ComponentPlacement.RELATED)
                        .addGroup(layout.createParallelGroup(javax.swing.GroupLayout.Alignment.BASELINE)
                            .addComponent(jLabel7)
                            .addComponent(lblPrisonName))
                        .addPreferredGap(javax.swing.LayoutStyle.ComponentPlacement.RELATED)
                        .addGroup(layout.createParallelGroup(javax.swing.GroupLayout.Alignment.BASELINE)
                            .addComponent(jLabel9)
                            .addComponent(lblCellNumber)))
                    .addComponent(jScrollPane1, javax.swing.GroupLayout.DEFAULT_SIZE, 141, Short.MAX_VALUE))
                .addGap(18, 18, 18)
                .addComponent(btn_Close)
                .addContainerGap())
        );

        pack();
    }// </editor-fold>//GEN-END:initComponents

    private void btn_CloseActionPerformed(java.awt.event.ActionEvent evt) {//GEN-FIRST:event_btn_CloseActionPerformed
        this.dispose();
    }//GEN-LAST:event_btn_CloseActionPerformed

private void lblPrisonerNameMouseEntered(java.awt.event.MouseEvent evt) {//GEN-FIRST:event_lblPrisonerNameMouseEntered
    lblPrisonerName.setForeground(Color.BLUE);
}//GEN-LAST:event_lblPrisonerNameMouseEntered

private void lblPrisonerNameMouseExited(java.awt.event.MouseEvent evt) {//GEN-FIRST:event_lblPrisonerNameMouseExited
    lblPrisonerName.setForeground(Color.BLACK);
}//GEN-LAST:event_lblPrisonerNameMouseExited

private void lblPrisonerNameMousePressed(java.awt.event.MouseEvent evt) {//GEN-FIRST:event_lblPrisonerNameMousePressed
    DetailedCriminal _criminal = new DetailedCriminal(null, true, new Criminal(prisoner.getRelatedCriminal().getID()));
    _criminal.setVisible(true);
}//GEN-LAST:event_lblPrisonerNameMousePressed

    /**
     * @param args the command line arguments
     */
    public static void main(String args[]) {
        java.awt.EventQueue.invokeLater(new Runnable() {

            public void run() {
                DetailedPrisoner dialog = new DetailedPrisoner(new javax.swing.JFrame(), true);
                dialog.addWindowListener(new java.awt.event.WindowAdapter() {

                    public void windowClosing(java.awt.event.WindowEvent e) {
                        System.exit(0);
                    }
                });
                dialog.setVisible(true);
            }
        });
    }
    // Variables declaration - do not modify//GEN-BEGIN:variables
    private javax.swing.JButton btn_Close;
    private javax.swing.JLabel jLabel1;
    private javax.swing.JLabel jLabel11;
    private javax.swing.JLabel jLabel13;
    private javax.swing.JLabel jLabel2;
    private javax.swing.JLabel jLabel3;
    private javax.swing.JLabel jLabel5;
    private javax.swing.JLabel jLabel7;
    private javax.swing.JLabel jLabel9;
    private javax.swing.JPanel jPanel1;
    private javax.swing.JScrollPane jScrollPane1;
    private javax.swing.JLabel lblCellNumber;
    private javax.swing.JLabel lblImprisonDate;
    private javax.swing.JLabel lblIsReleased;
    private javax.swing.JLabel lblPrisonName;
    private javax.swing.JLabel lblPrisonerName;
    private javax.swing.JLabel lblReleaseDate;
    private javax.swing.JTextArea txtReleaseReason;
    // End of variables declaration//GEN-END:variables
}
